package com.wanshu.config;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.sun.org.apache.xml.internal.utils.StringToStringTable;

import java.util.Collections;

//mybatispuls代码生成器
public class MyBatisGeneratorConfiguration {

    public static void main(String[] args) {
        Class<?> clazz = MyBatisGeneratorConfiguration.class;
        Package pkg = clazz.getPackage();
        String packageName = pkg.getName();
        String packagePath = packageName.replace(".", "/");
        System.out.println("当前所在目录: " + packagePath);
        //packagePath = packagePath.lastIndexOf()
        FastAutoGenerator.create("jdbc:mysql://192.168.1.20:3309/wanshu_crm?" +
                "serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&" +
                "useSSL=true&nullCatalogMeansCurrent=true", "root", "123456").
                globalConfig(builder -> {builder.author("波哥").enableSwagger()
                        .fileOverride().outputDir("E:\\Idea_Workspace\\WSCRM\\src\\main\\java"); }).
                packageConfig(builder -> {builder.parent("com.wanshu").moduleName("sys").
                        pathInfo(Collections.singletonMap(OutputFile.xml, "E:\\Idea_Workspace\\WSCRM\\src\\main\\resources\\mapper\\sys"));}).
                strategyConfig(builder -> {builder.addInclude("sys_log");}).
                templateEngine(new FreemarkerTemplateEngine()).execute();

    }

}
